package freespiritsocial.io.user.weight

import android.app.Activity
import android.content.Context
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import com.bigkoo.pickerview.builder.OptionsPickerBuilder
import com.bigkoo.pickerview.view.OptionsPickerView
import freespiritsocial.io.user.R

class MyPickupViewBuilder(
    val context: Context?,
    private val decorView: View? = null,
    listener: ((option1: Int,option2: Int,option3: Int,view: View?) -> Unit)
):
    OptionsPickerBuilder(context,listener) {

    override fun <T> build(): OptionsPickerView<T> {
        var view: View? = null
        setDecorView(
            (decorView ?: ((context!! as Activity).window.decorView).findViewById(android.R.id.content)) as ViewGroup
        )
        setLayoutRes(R.layout.pickup_time_selector) {
            view = it
        }
        val build = super.build<T>()
        view?.findViewById<TextView>(R.id.btnSubmit)?.setOnClickListener {
            build.returnData()
            build.dismiss()
        }
        view?.findViewById<TextView>(R.id.btnCancel)?.setOnClickListener {
            build.dismiss()
        }
        return build
    }
}